import { CallBackHandler } from '../../Basic/Model/PoolObj/CallBackHandler';
import { PanelModel } from '../../Basic/UI/PanelModel';

export class SettlementModel extends PanelModel {
  className: string = 'SettlementModel';
  loadRes: string = 'maingame/settlement/SettlementPanel';

  isPass: boolean;
  // backHandler: CallBackHandler = null;
  continueHandler: CallBackHandler = null;

  // setContinueHandler(callback: () => unknown, target: unknown) {
  //   if (this.continueHandler === null) this.continueHandler = CallBackHandler.pop();

  //   this.continueHandler.unuse();
  //   this.continueHandler.reuse(callback, target);
  // }

  setHandler(callback: () => unknown, target: unknown) {
    if (this.continueHandler === null) this.continueHandler = CallBackHandler.pop();
    this.continueHandler.unuse();
    this.continueHandler.reuse(callback, target);
  }

  handleEvent() {
    // eslint-disable-next-line @typescript-eslint/no-unused-expressions
    this.continueHandler != null && this.continueHandler.execute();
    this.continueHandler.unuse();
  }

  // handleBackEvent() {
  //   // eslint-disable-next-line @typescript-eslint/no-unused-expressions
  //   this.backHandler != null && this.backHandler.execute();
  //   this.backHandler.unuse();
  // }
}
